/*
 *  dna_logdump.h -- provide dna-system logdump client implementation.
 *
 *  ORIGINAL AUTHOR: Xu Chun (chun.xu@broadlink.com.cn)
 *
 *  Copyright (c) 2016 Broadlink Corporation
 */

#ifndef __DNA_LOGDUMP_H
#define __DNA_LOGDUMP_H

#define LOGDUMP_MSG_SIZE                            128

#define CONFIG_LOGDUMP_DRV_NET
#define CONFIG_LOGDUMP_QDISC_FIFO

#define CONFIG_LOGDUMP_DRV                          DNA_LOGDUMP_DRIVER_NET
#define CONFIG_LOGDUMP_QDISC                        DNA_LOGDUMP_QDISC_DIRECT

/* Logdump module support driver list */
enum {
    DNA_LOGDUMP_DRIVER_UART         =  0,
    DNA_LOGDUMP_DRIVER_WIFI,
    DNA_LOGDUMP_DRIVER_NET,
    DNA_LOGDUMP_DRIVER_RF,
    DNA_LOGDUMP_DRIVER_DISK,    /* Filesystem */
    DNA_LOGDUMP_DRIVER_MAX,
};

/* Logdump module support QoS list */
enum {
    DNA_LOGDUMP_QDISC_DIRECT        =  0,
    DNA_LOGDUMP_QDISC_FIFO,
    DNA_LOGDUMP_QDISC_MAX,
};

/*
*  Logdump network server address (used for net driver).
*/
typedef struct logdump_net_servaddr {
    unsigned int ipaddr;
    unsigned short port;
    unsigned short res; /* Reserved */
} logdump_net_servaddr_t;

/*
*  Logdump module initialization.
*  @did: driver unique ID
*  @qid: qdisc unique ID
*
*  Return 0 on success.
*/
int dna_logdump_init(unsigned int did, unsigned int qid);

/*
*  Logdump module uninitialize.
*
*  Return 0 on success.
*/
int dna_logdump_deinit(void);

/*
*  Logdump module enable.
*
*  Return 0 on success.
*/
int dna_logdump_enable(void);

/*
*  Logdump module disable.
*
*  Return 0 on success.
*/
int dna_logdump_disable(void);

/*
*  Check logdump module whether is enable.
*  Return TRUE on running.
*/
int dna_logdump_is_enable(void);

/*
*  Logdump module switch request process interface.
*  Note: request maybe from socket or 802.11 management packet.
*  Return response packet length.
*/
int dna_logdump_switch_request(
        const void * request, int len,
        void * response, int maxsize);

/*
*  Check whether need enter or exit logdump mode.
*  Note: please call this API in sniffer callback or sta filter callback.
*  Return 0 on success.
*/
int dna_logdump_mgmtpkt_switch(const void * frame, unsigned short len);

/*
*  Logdump network server address set interface.
*  Return 0 on success.
*/
int dna_logdump_netserver_set(logdump_net_servaddr_t * server);

/*
*  Lead API.
*  It will nested in dna_printf.
*/
int dna_logdump(const char * fmt, ...);

#endif
